/**
* name 加载类
*/

import Image = laya.ui.Image;
import Text = laya.display.Text;
import GameCfg from "./GameCfg";

export default class Loading extends Image {

	private bg: Image;
	private txt: Text;

	constructor() {
		super();
		this.init();
	}

	private init(): void {
		//黑色背景
		this.bg = new Image();
		this.bg.graphics.drawRect(0, 0, GameCfg.GameWidth, GameCfg.GameHeight, "#000000");
		this.addChild(this.bg);

		//loading文本
		this.txt = new Text();
		this.txt.color = "#ffffff";
		this.txt.fontSize = 30;
		this.txt.text = "Loading";
		this.txt.width = GameCfg.GameWidth;
		this.txt.align = "center";
		this.txt.y = (GameCfg.GameHeight - this.txt.height) * 0.5;
		this.addChild(this.txt);
	}

	public progress(value: number): void {
		this.txt.text = "Loading " + Math.floor(value * 100) + "%";
	}

}